package com.cl.ks.constant;

import com.cl.ks.entity.*;

import java.io.File;
import java.util.Arrays;

public class QTableConstant {
    public static void main(String[] args) {
        // 假设entity文件夹位于项目的根目录下
        File entityFolder = new File("/Users/chenlong/mine/ks-service/pile-service/src/main/java/com/jandar/entity");

        // 读取entity文件夹中的所有文件
        File[] files = entityFolder.listFiles();
        if (files == null) {
            System.out.println("无法读取entity文件夹");
            return;
        }

        // 过滤出.java文件并生成类名列表
        String[] classNames = Arrays.stream(files)
                .filter(file -> file.isFile() && file.getName().endsWith(".java"))
                .map(file -> file.getName().substring(0, file.getName().length() - 5)) // 去掉.java扩展名
                .toArray(String[]::new);

        // 生成QTableConstant类
        String generatedCode = generateQTableConstantClass(classNames);

        // 输出生成的代码（或将其写入文件）
        System.out.println(generatedCode);
    }

    private static String generateQTableConstantClass(String[] classNames) {
        StringBuilder sb = new StringBuilder();
        sb.append("public class QTableConstant {\n\n");

        for (String className : classNames) {
            // 假设每个类都有一个名为ksRule或ksFilter的静态成员
            String fieldName = "q" + className.substring(0, 1).toUpperCase() + className.substring(1);
            String initializer = "Q" + className + "." + className.substring(0,1).toLowerCase() + className.substring(1); // 或 className + ".ksFilter"，根据需要选择
            sb.append("    public static final Q").append(className).append(" ").append(fieldName).append(" = ").append(initializer).append(";\n\n");
        }

        sb.append("}\n");
        return sb.toString();
    }
    public static final QKsRule qKsRule = QKsRule.ksRule;

    public static final QKsFilter qKsFilter = QKsFilter.ksFilter;

    public static final QKsFilterResult qKsFilterResult = QKsFilterResult.ksFilterResult;

    public static final QKsFilterStatistics qKsFilterStatistics = QKsFilterStatistics.ksFilterStatistics;

    public static final QKsIncrement qKsIncrement = QKsIncrement.ksIncrement;

    public static final QKsTable qKsTable = QKsTable.ksTable;

    public static final QKsTableField qKsTableField = QKsTableField.ksTableField;

    public static final QKsTableJoin qKsTableJoin = QKsTableJoin.ksTableJoin;

    public static final QSysSourceConfig qSysSourceConfig = QSysSourceConfig.sysSourceConfig;

    public static final QSysSourceMappingTable qSysSourceMappingTable = QSysSourceMappingTable.sysSourceMappingTable;

    public static final QSysSourceMappingTableField qSysSourceMappingTableField = QSysSourceMappingTableField.sysSourceMappingTableField;

    public static final QSystemCodeUrl qSystemCodeUrl = QSystemCodeUrl.systemCodeUrl;

    public static final QTaskList qTaskList = QTaskList.taskList;

    public static final QTaskListItem qTaskListItem = QTaskListItem.taskListItem;
    public static final QKsFilterLog qKsFilterLog = QKsFilterLog.ksFilterLog;
    public static final QRlRuleTable qRlRuleTable = QRlRuleTable.rlRuleTable;
    public static final QRlRuleField qRlRuleField = QRlRuleField.rlRuleField;
    public static final QKsDataField qKsDataField = QKsDataField.ksDataField;
    public static final QKsDataType qKsDataType = QKsDataType.ksDataType;

    public static final QKsClassField qKsClassField = QKsClassField.ksClassField;

    public static final QClueAutoResult qClueAutoResult = QClueAutoResult.clueAutoResult;
    public static final QKsFlowGraph qKsFlowGraph = QKsFlowGraph.ksFlowGraph;

    public static final QKsFlowGraphRecord qKsFlowGraphRecord = QKsFlowGraphRecord.ksFlowGraphRecord;
    public static final QKsFlowTask qKsFlowTask = QKsFlowTask.ksFlowTask;

    public static final QKsFlowResult qKsFlowResult = QKsFlowResult.ksFlowResult;
    public static final QKsFlowGraphLog qKsFlowGraphLog = QKsFlowGraphLog.ksFlowGraphLog;
    public static final QKsFlowLike qKsFlowLike = QKsFlowLike.ksFlowLike;
    public static final QKsFlowComment qKsFlowComment = QKsFlowComment.ksFlowComment;
    public static final QSqlTemplate qSqlTemplate = QSqlTemplate.sqlTemplate;

}
